<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8" />
<title>门店管理 - 门店库存列表</title>
<?php include($this->c['_homes']['_viewsHome'].'/_global/_head.php');?>
</head>
<!-- BEGIN BODY -->
<body class="page-header-fixed page-sidebar-fixed">
<!-- BEGIN HEADER -->
<?php include($this->c['_homes']['_viewsHome'].'/_global/head.php');?>
<!-- END HEADER -->
<div class="clearfix"></div>
<!-- BEGIN CONTAINER -->
<div class="page-container" > 
  <!-- BEGIN HORIZONTAL MENU PAGE SIDEBAR1 -->
  <?php include($this->c['_homes']['_viewsHome'].'/_global/menu.php');?>
  <!-- END BEGIN HORIZONTAL MENU PAGE SIDEBAR --> 
  <!-- BEGIN PAGE -->
  <div class="page-content"> 
    <!-- BEGIN PAGE HEADER-->
    <div class="row">
      <div class="col-md-12"> 
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title"> 门店库存列表 </h3>
        <ul class="page-breadcrumb breadcrumb">
         <li> <i class="icon-home"></i> <a href="/manage">后台</a> <i class="icon-angle-right"></i> </li>
          <li> 门店管理 <i class="icon-angle-right"></i> </li>
          <li>门店库存列表</li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB--> 
      </div>
    </div>
    <!-- END PAGE HEADER--> 
    <!-- BEGIN PAGE CONTENT--> 
    <!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
    <div class="modal fade" id="portlet-config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <h4 class="modal-title">Modal title</h4>
          </div>
          <div class="modal-body"> Widget settings form goes here </div>
          <div class="modal-footer">
            <button type="button" class="btn blue submit_btn">确定</button>
            <button type="button" class="btn default" data-dismiss="modal">取消</button>
          </div>
        </div>
        <!-- /.modal-content --> 
      </div>
      <!-- /.modal-dialog --> 
    </div>
    <!-- /.modal --> 
    <!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
    <div class="row">
      <div class="col-md-12">
        <div class="portlet box">
          <div class="booking-search">
            <form action="" role="form" method="get">
              <div class="row form-group">
                <div class="col-md-3">
                  <div class="input-cont">
                    <input class="form-control" name="keyword" placeholder="商品名称/条码/ID" value="<?=$_GET['keyword'];?>" type="text">
                  </div>
                </div>

                
                <div class="col-md-2">
                  <select class="form-control" name="caid" id="caid">
                    <option value="">商品分类</option>
                      <?php
                      if($this->cate){
                          foreach($this->cate[0] as $k=> $r){
                              if(isset($this->data['para']['caid']) && $k==$this->data['para']['caid']) $slk = ' selected';
                              else $slk = '';

                                $newcate[$r['caid']] = $r['name'];
                              ?>
                              <option value="<?=$r['caid'];?>"<?=$slk;?>><?=$r['name'];?></option>
                              <?php
                              if($this->cate[$r['caid']]){
                                  foreach($this->cate[$r['caid']] as $j=>$s){
                                      if(isset($this->data['para']['caid']) && $j==$this->data['para']['caid']) $slk = ' selected';
                                      else $slk = '';

                                        $newcate[$s['caid']] = $s['name'];
                                      ?>
                                      <option value="<?=$s['caid'];?>"<?=$slk;?>>&nbsp;&nbsp;&nbsp;&nbsp;<?=$s['name'];?></option>
                                      <?
                                  }
                              }?>
                              <?
                          }
                      }
                      ?>

                  </select>
                </div>

                <div class="col-md-2">
                  <select class="form-control" name="brand_id" id="brand_id">
                      <option value="">商品品牌</option>
                      <?php
                            if($this->brand){
                              foreach($this->brand as $py => $bd){
                                foreach($bd as $r)
                                {
                                  if(isset($this->data['para']['brand_id']) && $r['brand_id']==$this->data['para']['brand_id']) $slk = ' selected';
                                  else $slk='';
                                  $newbrand[$r['brand_id']] = $r['name'];
                                  
                                  echo '<option value="'.$r['brand_id'].'"'.$slk.'>'.$py.' '.stripslashes($r['name']).'</option>';
                                }                              
                              }
                            }             
                            ?> 

                  </select>
              </div>

              <div class="col-md-2">
                  <select class="form-control" name="store_id" id="_store_id">
                      <option value="">门店</option>
                      <?php
                      if($this->store){
                          foreach($this->store as $k=> $r){
                              if(isset($this->data['para']['store_id']) && $r['store_id']==$this->data['para']['store_id']) $slk = ' selected';
                              else $slk = '';
                              $newstore[$r['store_id']] = $r['name'];
                              ?>
                              <option value="<?=$r['store_id'];?>"<?=$slk;?>><?=$r['name'];?></option>
                              <?
                          }
                      }
                      ?>
                  </select>
              </div>
                <div class="col-md-2">
                  <select class="form-control" name="is_on_sale">
                    <option value="">上下架</option>
                    <option value="1"<? if($this->data['para']['is_on_sale']==1) echo ' selected';?>>上架</option>
                    <option value="0"<? if( isset($this->data['para']['is_on_sale']) && $this->data['para']['is_on_sale']==0) echo ' selected';?>>下架</option>
                  </select>
                </div>
                <div class="col-md-1">
                  <input type="submit" class="btn blue btn-block" value="搜 索">
                </div>
                </div>
            </form>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-md-12"> 
        <!-- BEGIN SAMPLE TABLE PORTLET-->
        <div class="portlet box blue">
            <div class="portlet-title">
            <div class="caption"><i class="icon-list"></i>列表(<?=$this->data['count'];?>)</div>
            <div class="actions">
            </div>
          </div>
          <div class="portlet-body">
            <div class="table-scrollable">
             <table class="table table-striped table-bordered table-hover dataTable">
                <thead>
                  <tr>                    
                    <th>商品ID</th>
                    <th>名称</th>
                    <th>商品SKU</th>
                    <th>分类</th>
                    <th>品牌</th>
                    <th>门店</th>
                    <th>商品图片</th>
                    <th>零售价</th>
                    <th>市场价</th>
                    <th>进货价</th>
                    <th>库存</th>
                    <th>上架</th>
                    <th>操作</th>             
                  </tr>
                </thead>
                <tbody>
                 <?php if($this->data['data']){
            				foreach($this->data['data'] as $k=> $r){		
						      ?>
                  <tr>                    
                    <td><?=$r['goods_id'];?></td>
                    <td><?=$r['goods_name'];?></td>
                    <td><?=$r['goods_sku'];?></td>
                    <td><?=$newcate[$r['caid']];?></td>
                    <td><?=$newbrand[$r['brand_id']];?></td>
                    <td><?=$newstore[$r['store_id']];?></td>
                    <td>
                    <?php if ($r['thumb_docid'] > 0){ ?>
                        <img src="<?=$this->data['docs'][$r['thumb_docid']]?>" width="60"/>
                    <?php }else{ ?>
                        <img src="<?=$this->data['docs'][$r['pic_docid']]?>" width="60" />
                    <?php }?>
                    </td>
                   
                    <td><?=$r['shop_price'];?></td>
                    <td><?=$r['market_price'];?></td>
                    <td><?=$r['purchase_price'];?></td>
                    <td><?=$r['number'] ;?></td>
                    <td><?=$this->c['stat']['yesno'][$r['is_on_sale']];?></td>
                   
                    <td>
                    <?                  
                    if($this->pv['stock']) echo ' <a href="stock_number?goods_id='.$r['goods_id'].'&store_id='.$r['store_id'].'"  class="btn btn-xs blue"><i class="icon-inbox"></i> 入库</a>';
                    if($this->pv['damaged']) echo ' <a href="stock_damaged?goods_id='.$r['goods_id'].'&store_id='.$r['store_id'].'"  class="btn btn-xs blue"><i class="icon-wrench"></i> 报损</a>';

                    ?>
                    </td>
                    </tr> <?php
          					}
          				}
          				?>
                </tbody>
              </table>
            </div>
          </div>
       
        <?php
    		if($this->data['maxpage'] > 1){
    		?>
            <div style="background-color:#fff;">
              <ul class="pagination" >
                <?
    			$pquery="?";		
    			if($this->data['para']){			
    				foreach($this->data['para'] as $k=>$r){				
    					$pquery.=$k."=".$r."&";
    					$form_hidden .= '<input type="hidden" name="'.$k.'" value="'.$r.'">';
    				}			
    			}
    			
    			if($this->data['page'] > 1) echo '<li><a href="'.$pquery.'page='.($this->data['page']-1).'"><i class="icon-angle-left"></i></a></li>';
    			for($i = $this->data['spage']['ps']; $i<=$this->data['spage']['pe']; $i++){
    			if($i == $this->data['page']) echo '<li class="disabled"><a href="javascript:void(0);">'.$i.'</a></li>';
    			else echo '<li><a href="'.$pquery.'page='.$i.'">'.$i.'</a></li>';
    			}
    			
    			if($this->data['page'] < $this->data['maxpage']) echo '<li><a href="'.$pquery.'page='.($this->data['page']+1).'"><i class="icon-angle-right"></i></a></li>';
    			?>
          </ul>
          <div class="jumppage">
          <form method="get" action="">
          <?=$form_hidden;?>
          页码：<?=$this->data['page'];?>/<?=$this->data['maxpage'];?>
          跳到 <input type="text" name="page" class="value"> 页          
          <input type="submit" value="GO" class="sub">
          </form>
          </div>
        </div>
        <?
 		}
?>
        <!-- END SAMPLE TABLE PORTLET--> 
      </div>
    </div>
    <!-- END PAGE CONTENT--> 
  </div>
  <!-- END PAGE --> 
</div>

<?php include($this->c['_homes']['_viewsHome'].'/_global/_footer.php');?>
<script>
  jQuery(document).ready(function() {    
     App.init();
  });
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>